// 商品数据
export const products = [
  {
    id: 1,
    name: '青岛啤酒经典款',
    price: 8.5,
    description: '青岛啤酒经典款，醇香口感，百年工艺传承',
    category: '酒水饮料',
    stock: 50,
    image: 'https://via.placeholder.com/150?text=Beer'
  },
  {
    id: 2,
    name: '海信4K智能电视',
    price: 3299,
    description: '55英寸4K超高清，智能安卓系统，MEMC运动补偿',
    category: '家用电器',
    stock: 15,
    image: 'https://via.placeholder.com/150?text=TV'
  },
  {
    id: 3,
    name: '海尔变频空调',
    price: 2899,
    description: '1.5匹变频，一级能效，自清洁技术，静音运行',
    category: '家用电器',
    stock: 8,
    image: 'https://via.placeholder.com/150?text=AC'
  },
  {
    id: 4,
    name: '青岛特产海鲜大礼包',
    price: 168,
    description: '精选青岛本地海鲜，包含虾干、鱼片、海米等多种美味',
    category: '食品特产',
    stock: 35,
    image: 'https://via.placeholder.com/150?text=Seafood'
  },
  {
    id: 5,
    name: '双星运动鞋',
    price: 199,
    description: '轻便舒适，防滑耐磨，透气网面设计',
    category: '服装鞋帽',
    stock: 42,
    image: 'https://via.placeholder.com/150?text=Shoes'
  },
  {
    id: 6,
    name: '崂山绿茶礼盒',
    price: 128,
    description: '明前特级崂山绿茶，清香甘醇，礼盒包装',
    category: '食品特产',
    stock: 27,
    image: 'https://via.placeholder.com/150?text=Tea'
  },
  {
    id: 7,
    name: '海尔滚筒洗衣机',
    price: 2599,
    description: '10公斤大容量，蒸汽除菌，智能投放',
    category: '家用电器',
    stock: 6,
    image: 'https://via.placeholder.com/150?text=Washer'
  },
  {
    id: 8,
    name: '青岛即食海参',
    price: 298,
    description: '即食海参，营养丰富，开袋即食',
    category: '食品特产',
    stock: 18,
    image: 'https://via.placeholder.com/150?text=SeaCucumber'
  }
];

// 模拟API延迟
const simulateDelay = (min = 300, max = 800) => {
  return new Promise(resolve => {
    const delay = Math.floor(Math.random() * (max - min + 1)) + min;
    setTimeout(resolve, delay);
  });
};

// 获取所有商品
export const fetchProducts = async () => {
  await simulateDelay();
  return products;
};

// 根据ID获取商品
export const fetchProductById = async (id) => {
  await simulateDelay();
  const product = products.find(p => p.id === parseInt(id));
  return product || null;
};